package com.woniu.cq.mallcommon.service.impl;

import com.woniu.cq.mallcommon.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class SmsServiceImpl implements SmsService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public void send(String mobile, String code) {
        final String message = String.format("【蜗牛学院】验证码是%s,请在5分钟内输入", code);
        stringRedisTemplate.opsForValue().set("mobile:"+mobile,"code:"+code);
        //发送验证码操作，出现异常时抛出异常
        System.out.println("------>" + message);

    }
}
